package com.learn.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

										

import com.learn.dao.BookDao;
import com.learn.entity.BookEntity;
import com.learn.service.BookService;
import com.learn.service.*;



@Service("bookService")
public class BookServiceImpl implements BookService {
	@Autowired
	private BookDao bookDao;

			

			

			            @Autowired
            private  TypeService  typeService;

		

			

			

			

			

			

			

			

	

	
	@Override
	public BookEntity queryObject(Long id){
			BookEntity entity = bookDao.queryObject(id);

									
            if ( entity.getType() != null &&  this.typeService.queryObject(entity.getType()) != null)
                entity.setTypeEntity(this.typeService.queryObject(entity.getType()));

																								
		return entity;
	}
	
	@Override
	public List<BookEntity> queryList(Map<String, Object> map){
        List<BookEntity> list = bookDao.queryList(map);
        for(BookEntity entity : list){
																					
                    if ( entity.getType() != null &&  this.typeService.queryObject(entity.getType()) != null)
                        entity.setTypeEntity(this.typeService.queryObject(entity.getType()));

																																																										}
		return list;
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return bookDao.queryTotal(map);
	}
	
	@Override
	public void save(BookEntity book){
		bookDao.save(book);
	}
	
	@Override
	public void update(BookEntity book){
		bookDao.update(book);
	}
	
	@Override
	public void delete(Long id){
		bookDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Long[] ids){
		bookDao.deleteBatch(ids);
	}
	
}
